<template>
	<!-- 积分商品列表 -->
	<view>
		<!-- #ifdef APP-PLUS -->
		<view class="status_bar"></view>  
		<!-- #endif -->
		<navbar title="商品列表" />
		<integral :goodsList="integralGoodsList" goodsType="2" />
		<!-- 加载更多 -->
		<pullDownRefresh :status="loading" style="padding-bottom: 130rpx;" />
	</view>
</template>

<script>
	import integral from '@/components/goodslist/index_integral_all'
	import pullDownRefresh from '@/components/pullDownRefresh'
	export default {
		components:{
			integral,
			pullDownRefresh
		},
		data() {
			return {
				id:0,
				page:1,
				integralGoodsList:[],
				loading:0
			}
		},
		onLoad(options) {
			this.id = options.id;
			uni.showLoading({
				title:'加载中...'
			})
			this.getIntegralGoodslist();
		},
		onReachBottom() {
			this.page++;
			this.getIntegralGoodslist();
		},
		methods: {
			//获取积分商品列表
			getIntegralGoodslist(){
				this.loading = 1;
				this.$api.shopallgoods({
					offset:this.page,
					type:2
				}).then(res=>{
					uni.hideLoading();
					if(res.length>0){
						this.loading = 0;
						this.integralGoodsList = this.integralGoodsList.concat(res);
					}else{
						this.loading = 3;
						// uni.showToast({
						// 	title:'没有更多了~',
						// 	icon:'none'
						// })
					}
				})
			}
		}
	}
</script>

<style lang="scss">
page{
	padding-top: calc(var(--status-bar-height) + 130rpx);
}
</style>
